﻿using System;
using System.Runtime.InteropServices;
using System.Text;
using zakalib;

namespace csharp_test
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Begin!");
            //zakka.print_str("asdfasdf");
            //zakka.print_str2(Encoding.UTF8.GetBytes("中文\0"));
            //StringHandle handle = zakka.generate_str();
            //string result = handle.AsString();

            //zakka.print_str2(Marshal.StringToCoTaskMemUTF8("中文"));

            //IntPtr intptr = zakka.generate_str();
            //string result = Marshal.PtrToStringUTF8(intptr);
            //Console.WriteLine("c#-" + result);

            Zaka.Debug("写日志Debug");
            Zaka.Info("写日志Info");
            Zaka.Error("写日志Error");
            Zaka.Success("写日志Success");
            try
            {
                throw new Exception("出错了");
            }
            catch (Exception ex)
            {
                Zaka.Exception(ex);
            }
            Zaka.Custom("自定义1", "写日志Custom");
            Zaka.Custom("自定义2", "写日志Custom");


            //https://rustcc.cn/article?id=3ec2fda6-b79a-4fb0-ba5e-656bfa1a2cc2
            //http://www.moncci.com/
            //DateTime t1 = DateTime.Now;
            //string html = ZakkaEx.GetHtml("http://www.moncci.com/Blog/Detail?id=66");
            //Console.WriteLine(html);
            //DateTime t2 = DateTime.Now;
            //TimeSpan ts = t2 - t1;
            //Console.WriteLine(ts.TotalMilliseconds);

            int value1 = 345;
            Console.WriteLine(value1);
            Zaka.TestReceiveInt(value1);

            int value2 = Zaka.TestReturnInt();
            Console.WriteLine("C#收到数字数据：" + value2);


            string value3 = "C#发送中文字符串数据";
            Console.WriteLine(value3);
            Zaka.TestReceiveString(value3);

            string value4 = Zaka.TestReturnString();
            Console.WriteLine("C#收到中文字符串数据：" + value4);

            test_struct value5 = new test_struct();
            value5.user_age = 2566;
            value5.user_name = "张三二天";
            //value5.user_name = "afasfas";
            Zaka.TestReceiveStruct(value5);

            //byte[] array = { 12, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            //Zaka.test_receive_bytes(array);

            Console.WriteLine("End!");
            Console.ReadLine();
        }
    }
}
